﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>登陆页面</title>
    <link href="css/indexstyle.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="JavaScript/jquery-1.10.2.min.js" ></script>
    <script type="text/javascript" >

        if (window.top != window) {
            window.top.location.href = "Login.aspx";
        }

        function login() {
            var ipt_account = $("#account");
            var ipt_password = $("#password");
            var div_result = $("#result");
            if ($.trim(ipt_account.val()) == "" || $.trim(ipt_account.val()) == "请输入用户名") {
                div_result.html("用戶名不能空");
                ipt_account.focus();
                return;
            } else if ($.trim(ipt_password.val()) == "" || $.trim(ipt_password.val()) == "请输入密码") {
                div_result.html("密码不能为空");
                ipt_password.focus();
                return;
            }

            $.post("Login.aspx", { 'account': ipt_account.val(), 'password': ipt_password.val() },
                function (data) {
                    if (data.result) {
                        div_result.html("");
                        window.location.href = "index.aspx";
                    }
                    else
                        div_result.html(data.msg);
                },
                "json"
            ).error(function (data) {
                div_result.html("登陆出错，请检查服务器。");
            });
        }

        $(function () {
            var inputs = $(".userName_text");
            inputs.keypress(function (e) {
                if (e.which == 13) {// 判断所按是否回车键 
                    var idx = inputs.index(this); // 获取当前焦点输入框所处的位置  
                    if (idx == inputs.length - 1) {// 判断是否是最后一个输入框  
                        login();
                    } else {  
                        inputs[idx + 1].focus(); // 设置焦点  
                        inputs[idx + 1].select(); // 选中文字  
                    }  
                    return false;// 取消默认的提交行为  
                }  
            });  
        });

    </script>
</head>
<body style="background:#8cd5ff url(img/light.png) -400px 0 no-repeat;overflow: hidden;">
<div class="login_con">
    <div class="logo">经销商物品管理系统</div>
    <div class="login_bg">
        <div class="content">
           <h3>用户登录 <font>UserLogin</font></h3>
           <div class="input userName">
               <input type="text" name="" id="account" class="userName_text" value="请输入用户名" placeholder="请输入用户名" onfocus="if(value=='请输入用户名') {value='';}" onblur="if (value=='') {value='请输入用户名'}" />
           </div>
           <div class="input password">
               <input type="text" name="" id="password" class="userName_text" value="请输入密码" placeholder="请输入密码" onfocus="if(value=='请输入密码') {value='';type='password';}" onblur="if (value=='') {value='请输入密码';type='input';}"/>
           </div>
           <div class="text_button"><input type="button" name="" id="" class="button fl" value="登 录" onclick="login();" /></div>
            <div id="result" style="text-align:center;width: 320px; font-size: 16px; color: red;"></div>
        </div>
    </div>
</div>
</body>
</html>
